/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.madmac.ip;

import org.madmac.exception.CampoNaoInformadoException;
import java.sql.SQLException;
import org.madmac.join.PlacaRedeXMaquinas;

/**
 *
 * @author atila
 */
public class IpBo {

	private static IpBo instance;

	private IpBo () {

	}

	public static IpBo getInstance () {
		if (instance == null) {
			instance = new IpBo();
		}
		return instance;
	}

	public PlacaRedeXMaquinas validateSelectIpDetails (String search_ip)
			  throws CampoNaoInformadoException, SQLException, ClassNotFoundException, Exception {

		if (search_ip == null || search_ip.equals("")) {
			throw new CampoNaoInformadoException("O campo Buscar IP está vazio.");
		} else if (!search_ip.contains("/")) {
			throw new CampoNaoInformadoException("O IP deve conter a máscara na forma abreviada. Ex.: 10.50.0.1/8 ");
		} else if (!search_ip.contains(".")) {
			throw new CampoNaoInformadoException("O IP deve ser separado por pontos. Ex.: 10.50.0.1/8");
		}

		return PlacaRedeXMaquinas.getInstance().selectIpDetails(search_ip);
	}
}
